﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sinacor.Infra.Tools.ServiceRegistration.Entity
{
    public class Service : EntityBase
    {
        #region Attributes

        private int? _service_id;
        private string _service_name;
        private string _description;
        private List<Method> _methods;
        private List<EndPoint> _endpoints;
        private SubModule _sub_module;
        private StatusApproval? _StatusApproval;
        
        #endregion

        #region Constructor

        public Service()
        {
            _methods = new List<Method>();
            _endpoints = new List<EndPoint>();
        }

        #endregion

        #region Properties

        public int? ServiceId
        {
            get { return _service_id; }
            set { _service_id = value; }
        }

        public string ServiceName
        {
            get { return _service_name; }
            set { _service_name = value; }
        }

        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }

        public List<Method> Methods
        {
            get { return _methods; }
            set { _methods = value; }
        }

        public List<EndPoint> EndPoints
        {
            get { return _endpoints; }
            set { _endpoints = value; }
        }

        public string EndPointsText
        {
            get 
            {
                StringBuilder retorno = new StringBuilder();
                Boolean primeiro = true;
                foreach (Entity.EndPoint endPointItem in _endpoints)
                {
                    if(endPointItem.Protocol != null)
                    {
                        if (!primeiro)
                        {
                            retorno.Append(","); //usar mesmo separador na [function SetItemService] que chama [function SetListBox]) no arquivo [Scripts.js] - esertorio - 200811051000
                        }
                        retorno.Append(endPointItem.Protocol.ProtocolName);
                        primeiro = false;
                    }                        
                }
                return retorno.ToString();
            }
        }

        public SubModule SubModule
        {
            get { return _sub_module; }
            set { _sub_module = value; }
        }

        public StatusApproval? StatusApproval
        {
            get { return _StatusApproval; }
            set { _StatusApproval = value; }
        }

        #endregion
    }
}
